package test.java.com.project;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class ArrayList3 {
    public static void main(String[] args){
        ArrayList<String> l=new ArrayList<>();
        l.add("一号机器人");
        l.add("二号");
        l.add("三号");
        l.add(2,"测试有键值");
       // List<String> theString2=new ArrayList<String>(l);
        List<String> theString2=l;
        l.set(0,"替代品");

        List<String> theString=l.subList(0,1);
        System.out.println(l);
        System.out.println(theString2);
        Iterator<String> iter=theString.iterator();
        while(iter.hasNext()){
            System.out.println(iter.next());
        }
        for(String s : l){
            System.out.println(s);
        }
    }
}
